package org.example.rzfx.task;

import lombok.extern.slf4j.Slf4j;
import org.example.rzfx.service.AlarmService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;

/**
 * 告警检查定时任务
 */
@Component
@Slf4j
public class AlarmCheckTask {
    
    @Resource
    private AlarmService alarmService;
    
    /**
     * 告警规则检查任务（每分钟执行一次）
     */
    @Scheduled(cron = "0 * * * * ?")
    public void checkAlarmRules() {
        log.info("开始执行告警检查任务...");
        
        try {
            alarmService.checkAlarmRules();
        } catch (Exception e) {
            log.error("告警检查任务执行失败", e);
        }
        
        log.info("告警检查任务完成");
    }
}

